package com.yanqu.road.server.cmd.wingroom.message;

import com.yanqu.road.pb.wingroom.WingRoomProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.wingroom.WingRoomMessageMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2022/3/18 9:08
 */
@Cmd(code = GameProtocol.S_WING_ROOM_CHANGE_MESSAGE_SWITCH, desc = "修改留言板留言开关")
public class ChangeMessageSwitchCmd extends AbstractCommand {
    private int switchType;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        WingRoomProto.ChangeMessageSwitchReqMsg reqMsg = WingRoomProto.ChangeMessageSwitchReqMsg.parseFrom(packet.getBytes());
        switchType = reqMsg.getSwitchType();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        WingRoomProto.ChangeMessageSwitchRespMsg.Builder respMsg = WingRoomMessageMgr.changeSelfMessageSwitch(player, switchType);
        player.sendPacket(ClientProtocol.U_WING_ROOM_CHANGE_MESSAGE_SWITCH, respMsg);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
